package com.liheng.yygh.common.exception;

import com.liheng.yygh.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: yygh_partn
 * @description: 全局异常处理
 * @author: _LiHeng
 * @create: 2022-12-19 10:37
 **/
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * @ExceptionHandler(Exception.class)
     * 如果程序出现异常,那么这个方法将会被执行
     * @return
     */
    @ExceptionHandler(YyghException.class)
    @ResponseBody
    public Result error(YyghException e){
        e.printStackTrace();
        return Result.fail();
    }

}
